from django.contrib import admin

from .models import Question, Choice

class ChoiceInline(admin.TabularInline):
    model = Choice
    extra = 1

class QuestionAdmin(admin.ModelAdmin):
    empty_value_display = '(None)'  # 空值
    list_display = ('question_text', 'pub_date', 'was_published_recently')
    list_filter = ['pub_date']         
    search_fields = ['question_text']  # 查询条件
    fieldsets = [
        ('问题', {'fields': ['question_text', 'pub_date']}),
    ]

    inlines = [ChoiceInline]

admin.site.register(Question, QuestionAdmin)
